package com.example.three.Service.SysShopService;

import com.example.three.DO.SysOfficeProd;
import com.example.three.Mapper.ShopMapper.ShopMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class SysShopServiceImpl implements SysShopService{

    @Resource
    private ShopMapper shopMapper;

    @Override
    public List<SysOfficeProd> profindBy(String shopId) {

        return shopMapper.profindBy(shopId);
    }

    @Override
    public SysOfficeProd profindBy1(long proId) {
        return shopMapper.profindBy1(proId);
    }

    @Override
    public int prodelete(String shopId, long prodId) {
        return shopMapper.prodelete(shopId,prodId);
    }

    @Override
    public List<SysOfficeProd> selectgood(String shopId,String prod_name){
        return shopMapper.selectgood(shopId,prod_name);
    }

    @Override
    public int addpro(long proId, String proName, String proType, String shopId, String isConsume, String price,
                      String pic, String status, String totalStocks,long salesVolume) {
        Date date = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.sql.Timestamp createTime = Timestamp.valueOf(formatter.format(date));
        return shopMapper.addpro(proId,proName,proType,shopId,isConsume,price,pic,status,totalStocks,createTime,createTime,createTime,salesVolume);
    }

    @Override
    public int setpro(long proId, String proName, String proType, String shopId, String isConsume,
                      String price, String pic, String status, String totalStocks) {
        Date date = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        java.sql.Timestamp createTime = Timestamp.valueOf(formatter.format(date));
        return shopMapper.setpro(proId,proName,proType,shopId,isConsume,price,pic,status,totalStocks,createTime);
    }

    @Override
    public int updatenumber(long proId, String totalStocks) {
        return shopMapper.updatenumber(proId,totalStocks);
    }

}
